package com.ellricky.tc_manager.ui

import android.os.Bundle
import com.andr.common.ui.activity.BaseActivity
import com.andr.common.ui.mvp.BasePresenter
import com.andr.common.widget.bnb.BnbUtil
import com.ellricky.baselib.BaseConstant
import com.ellricky.baselib.adapter.course.MakeUpCourseListMainFragment
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.ui.SchoolOverviewFragment
import com.ellricky.baselib.ui.msg.MsgTipFragment
import com.ellricky.baselib.ui.order.ClassConsumeFragment
import com.ellricky.baselib.ui.student.StudentManageFragment
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.tc_manager.R
import com.ellricky.tc_manager.ui.home.TeachManageMainFragment
import kotlinx.android.synthetic.main.tm_activity_main.*

class TeachManagerMainActivity : BaseActivity<Void, BasePresenter<Void>>() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        LocalCacheUtil.setIsReloadData(true)
    }


    override fun onPause() {
        super.onPause()
        LocalCacheUtil.setIsReloadData(false)
    }

    override fun getContentLayout(): Int {
        return R.layout.tm_activity_main
    }

    override fun initUIView() {
        val bundle = Bundle().apply {
            putBoolean(BaseConstant.KEY_SHOW_BACK, false)
        }
        mainView.initVP(
            listOf(
                TeachManageMainFragment.newInstance(),
                StudentManageFragment.newInstance(),
                ClassConsumeFragment.newInstance(bundle),
                MsgTipFragment.newInstance(BaseConstant.CARD_TEACHER_MANAGER),
                SchoolOverviewFragment.newInstance()
            ), supportFragmentManager
        )

        mainView.initBnb(
            mutableListOf(
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_home_sel,
                    R.drawable.base_icon_home_nor,
                    R.string.base_home
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_stu_manage_sel,
                    R.drawable.base_icon_stu_manage_nor,
                    R.string.base_stu_manage
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_task_sel,
                    R.drawable.base_icon_task_nor,
                    R.string.base_consume_title
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_integral_sel,
                    R.drawable.base_icon_integral_nor,
                    R.string.base_msg_tip
                ),
                BnbUtil.addBnbItem(
                    this,
                    R.drawable.base_icon_msg_tip_sel,
                    R.drawable.base_icon_msg_tip_nor,
                    R.string.base_my_achievement
                )
            )
        )

    }

    override fun onKeyBack(isKeyBack: Boolean) {
        EAppUtil.exitApp(this)
    }
}
